<?php
class Auth {
    static function userHasProfile() {
        if (isset($_SESSION['userdata']['company_profile_id'])) { return true; }
        return false;
    }
    
    static function getProfileId() {
        return $_SESSION['userdata']['company_profile_id'];
    }

    static function getUserProperty($propertyname, $default = false) {
        if (isset($_SESSION['userdata'][$propertyname])) {
            return $_SESSION['userdata'][$propertyname];
        }
        return $default;
    }

    static function setUserProperty($propertyName, $value) {
        $_SESSION['userdata'][$propertyName] = $value;
    }

    static function setCompanyProfileId($id) {
        $_SESSION['userdata']['company_profile_id'] = $id;
    }
    
    static function logout() {
        unset($_SESSION['userdata']);
    }

    static function isLoggedIn() {
        return isset($_SESSION['userdata']);
    }

    static function getDumpUserData() {
        return $_SESSION['userdata'];
    }

    static function isAdmin() {
        return $_SESSION['userdata']['role'] == "2";
    }
}

?>
